package com.hys.ultrasound.base.ui;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.blankj.utilcode.util.LogUtils;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @desc:所有activity基类
 * @date:2019/1/29 9:57
 * @auther:lp
 * @version:1.0
 */
public abstract class BaseFragment extends Fragment {
    protected Activity mActivity;
    protected Context mContext;
    private Unbinder unbinder;
    protected int num=-1;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mActivity = getActivity();
        mContext = getContext();
        LogUtils.e("onCreateView()  "+getClass().getSimpleName()+" num = "+num);
        View root = inflater.inflate(getLayoutResId(), container, false);
        unbinder = ButterKnife.bind(this, root);
        return root;
    }

    /**
     * 得到布局id
     *
     * @return
     */
    protected abstract int getLayoutResId();

    @Override
    public void onDestroyView() {
        if (unbinder != null) {
            unbinder.unbind();
        }
        super.onDestroyView();
    }
}
